home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ldb.zip / BDRDEM2.CPP < prev    next >
C/C++ Source or Header  |  1991-10-18  |  1KB  |  58 lines

  1.     // bdrdem2.cpp
  2.     // Demo some stack, queue, list, array, and sort
  3.     // member functions.
  4.     // Link with binder.obj
  5.  
  6.     #include <string.h>    
  7.     #include <iomanip.h>
  8.     #include "binder.hpp"
  9.  
  10.  
  11.     main()
  12.     {
  13.         Binder B;
  14.         
  15.         B.push("Now is the time");
  16.         B.atIns(B.Nodes(),"for all programmers");
  17.         B.insQ("to stop reinventing");
  18.         B.setCurNode(B.Nodes()-1);
  19.         B.ins("the linked list!");
  20.         
  21.         cout << "\n\nBinder contains the following "
  22.             << "nodes:  \n\n";
  23.     
  24.         for (B.setCurNode(); B++;
  25.             cout << (char *)(voiD) B << endl);
  26.             
  27.         cout << "\n\nPress enter to continue ... ";
  28.         cin.get();
  29.         
  30.  
  31.         
  32.         
  33.         Binder B2;
  34.         
  35.         B2.setComparE((BDRcomparE)strcmp);
  36.         
  37.         while (B2.insSort(B++));
  38.             
  39.         B.sort((BDRcomparE)strcmp);
  40.         
  41.         cout << "\n\nAnd the Binder sorted:\n\n";        
  42.  
  43.         while (B.setCurNode(0))
  44.             cout << (char *) B.del() << endl;
  45.             
  46.         cout << "\n\nAnd an alternate Binder "
  47.             "insertion sorted:\n\n";
  48.             
  49.         while (B2.Nodes())
  50.             cout << (char *) B2.pop() << endl;
  51.             
  52.  
  53.         cout << "\n\nPress enter to quit ... ";
  54.         cin.get();
  55.  
  56.         return 0;
  57.     }
  58.